package com.jjb.www.ui.activity;

import androidx.appcompat.app.AppCompatActivity;
import androidx.core.content.ContextCompat;

import android.annotation.SuppressLint;
import android.os.Bundle;
import android.view.View;

import com.hjq.base.BaseDialog;
import com.hjq.shape.layout.ShapeLinearLayout;
import com.hjq.shape.view.ShapeButton;
import com.jjb.www.R;
import com.jjb.www.app.AppActivity;
import com.jjb.www.ui.dialog.MessageDialog;
/**
 *    author : Android CRG
 *    time   : 2019/03/01
 *    desc   : 申请电子发票
 */
public class InvoiceActivity extends AppActivity {
    private ShapeButton mBtnEnterprise;
    private ShapeButton mBtnPersonal;
    private ShapeLinearLayout mLlEnterprise;
    private ShapeLinearLayout mLlPersonal;
    private ShapeButton mBtnGo;

    @Override
    protected int getLayoutId() {
        return R.layout.activity_invoice;
    }

    @Override
    protected void initView() {
        mBtnEnterprise = findViewById(R.id.btn_enterprise);
        mBtnPersonal = findViewById(R.id.btn_personal);
        mLlEnterprise = findViewById(R.id.ll_enterprise);
        mLlPersonal = findViewById(R.id.ll_personal);
        mBtnGo = findViewById(R.id.btn_go);
        setOnClickListener(mBtnGo,mBtnEnterprise,mBtnPersonal);
    }

    @SuppressLint("ResourceType")
    @Override
    public void onClick(View view) {
        if (view==mBtnPersonal){
            mLlPersonal.setVisibility(View.VISIBLE);
            mLlEnterprise.setVisibility(View.GONE);
            mBtnPersonal.getShapeDrawableBuilder()
                    .setSolidColor(ContextCompat.getColor(getContext(), R.color.color_0B77D5))
                    .intoBackground();
            mBtnPersonal.getTextColorBuilder()
                    .setTextColor(ContextCompat.getColor(getContext(), R.color.white))
                    .intoTextColor();

            mBtnEnterprise.getShapeDrawableBuilder()
                    .setSolidColor(ContextCompat.getColor(getContext(), R.color.color_EFEFEF))
                    .intoBackground();
            mBtnEnterprise.getTextColorBuilder()
                    .setTextColor(ContextCompat.getColor(getContext(), R.color.color_2F2F2F))
                    .intoTextColor();

        }else if (view==mBtnEnterprise){
            mLlPersonal.setVisibility(View.GONE);
            mLlEnterprise.setVisibility(View.VISIBLE);

            mBtnEnterprise.getShapeDrawableBuilder()
                    .setSolidColor(ContextCompat.getColor(getContext(), R.color.color_0B77D5))
                    .intoBackground();
            mBtnEnterprise.getTextColorBuilder()
                    .setTextColor(ContextCompat.getColor(getContext(), R.color.white))
                    .intoTextColor();

            mBtnPersonal.getShapeDrawableBuilder()
                    .setSolidColor(ContextCompat.getColor(getContext(), R.color.color_EFEFEF))
                    .intoBackground();
            mBtnPersonal.getTextColorBuilder()
                    .setTextColor(ContextCompat.getColor(getContext(), R.color.color_2F2F2F))
                    .intoTextColor();
        }else if (view==mBtnGo){
            new MessageDialog.Builder(getActivity())
                    // 标题可以不用填写
//                    .setTitle("")
                    .setTitle(R.mipmap.icon_message_title)
                    // 内容必须要填写
                    .setMessage("申请信息提交后不可更改，发票一旦开出后不可退改，请确认您的开票信息是否正确？")
                    // 确定按钮文本
                    .setConfirm("确认提交")
                    // 设置 null 表示不显示取消按钮
                    .setCancel("取消修改")
                    // 设置点击按钮后不关闭对话框
//                    .setAutoDismiss(false)
                    .setListener(new MessageDialog.OnListener() {

                        @Override
                        public void onConfirm(BaseDialog dialog) {
                        }

                        @Override
                        public void onCancel(BaseDialog dialog) {
                        }
                    })
                    .show();
        }
    }

    @Override
    protected void initData() {

    }
}